home *** CD-ROM | disk | FTP | other *** search
- /**
- * DEMOEDT.C Simple example of Turbo C TOOLS edit function
- * usage.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1987, 1989
- *
- **/
-
-
- #include <bedit.h>
- #include <bstrings.h>
- #include <stdio.h>
-
- #define FIELD_WIDTH 30
- #define FIELD_HEIGHT 5
-
- void main(void);
- char returned_string[FIELD_WIDTH * FIELD_HEIGHT + 1];
-
- void main()
- {
- int error_code;
- ED_CONTROL field_control;
- int cursor_was_off,row,col,high,low;
- char *pinitial_string =
- "This is a demonstration of the Turbo C TOOLS edit functions.";
- KEY_SEQUENCE final_key;
-
- cursor_was_off = sccurst(&row,&col,&high,&low);
-
- field_control.ul_corner.row = 0;
- field_control.ul_corner.col = 0;
- field_control.dimensions.h = FIELD_HEIGHT;
- field_control.dimensions.w = FIELD_WIDTH;
- field_control.attribute = 0x0007; /* Reverse video. */
- field_control.replace_cursor.high = 6; /* Underline */
- field_control.replace_cursor.low = 7; /* cursor. */
- field_control.insert_cursor.high = 0; /* Solid cursor. */
- field_control.insert_cursor.low = 7;
- field_control.control_function = (PKEY_CONTROL) NIL;
- field_control.control_flags = 0;
-
- scpclr();
-
- error_code = edfield(pinitial_string, returned_string,
- sizeof(returned_string),
- &field_control, &final_key);
-
- sccurset(FIELD_HEIGHT + 1, 0);
- scpgcur(cursor_was_off, high, low, CUR_NO_ADJUST);
-
- if ((error_code != ED_NO_ERROR) && (error_code != ED_USER_ABORT))
- {
- printf("Error %d editing.\n", error_code);
- exit(-1);
- }
-
- printf("Final key: char %02x, key %02x.\n",
- final_key.character_code, final_key.key_code);
-
- printf("Returned string:\n\"%s\"\n", returned_string);
- }